package day2;

/**
 * @author oldliu
 * @since 1.0
 */
public class Array3 {
    public static void main(String[] args) {
        //下标有含义（矢量）
        int []ar={10,44,34,14,4,3,15,23,22};
        //冒泡排序，从小到大
        for (int i=0;i<ar.length-1;i++){
            for (int j=0;j<ar.length-1-i;j++){ //0---length-2
                //和当前值j和右边的做比较
                if(ar[j]>ar[j+1]){
                    //互换
                    int temp=ar[j];
                    ar[j]=ar[j+1];
                    ar[j+1]=temp;
                }
            }
        }
        System.out.println("排序后：");
        for (int i = 0; i < ar.length; i++) {
            System.out.print(ar[i]+" ");
        }
        System.out.println();
    }
}
